﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp.Buttons
{
    public partial class SplitButtonDemo : Window, IWindow
    {
        public SplitButtonDemo()
        {
            InitializeComponent();

            this.splitButton2.PrimaryButtonClick += new EventHandler(splitButton1_PrimaryButtonClick);
            this.splitButton2.SecondaryButtonClick += new EventHandler(splitButton1_SecondaryButtonClick);
            this.splitButton2.SecondaryButtonPositionChanged += new EventHandler(splitButton1_SecondaryButtonPositionChanged);
        }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        public void SetTheme()
        {
        }

        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }

        void splitButton1_SecondaryButtonClick(object sender, EventArgs e)
        {
            int items = this.ListBox.Items.Count;
            this.ListBox.Items.Insert(0, items + "." + "SecondaryButton Click");
        }

        void splitButton1_PrimaryButtonClick(object sender, EventArgs e)
        {
            int items = this.ListBox.Items.Count;
            this.ListBox.Items.Insert(0, items + "." + "PrimaryButton Click");
        }

        void splitButton1_SecondaryButtonPositionChanged(object sender, EventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            if (this.splitButton2.SecondaryButtonPosition == ButtonPosition.Bottom || this.splitButton2.SecondaryButtonPosition == ButtonPosition.Top)
            {
                this.splitButton2.Height = 45;
            }
            else
            {
                this.splitButton2.Height = 25;
            }
        }

        private void radioButton2_Checked(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.SecondaryButtonPosition = ButtonPosition.Left;
        }

        private void radioButton3_Checked(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.SecondaryButtonPosition = ButtonPosition.Top;
        }

        private void radioButton4_Checked(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.SecondaryButtonPosition = ButtonPosition.Bottom;
        }

        private void radioButton1_Checked(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.SecondaryButtonPosition = ButtonPosition.Right;
        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.PrimaryContent = "High";
            this.splitButton2.IsDropDownOpen = false;
        }

        private void RadioButton_Checked_1(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.PrimaryContent = "Average";
            this.splitButton2.IsDropDownOpen = false;
        }

        private void RadioButton_Checked_2(object sender, RoutedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;

            this.splitButton2.PrimaryContent = "Low";
            this.splitButton2.IsDropDownOpen = false;
        }

        private void SpinEditor_ValueChanged(object sender, SpinEditorValueChangedEventArgs e)
        {
            if (this.splitButton2 == null)
                return;
   
            this.splitButton2.CornerRadius = new CornerRadius((double)e.Value);
        }
    }
}
